Symbolic link / Hard link on Windows
· One min read
Symbolic link
AKA SymLink / Soft link
- Symbolic link contains the text of target path
- If target move / remove, the link is broken
Hard link
- Hard link is meta data of the file, that is inode on Linux
- If target move / remove, the link is broken
Ref:
mklink
only available oncmd
, not onPowerShell
Create symbolic link
cmd
mklink <link> <source>
PowerShell
New-Item -ItemType SymbolicLink -Path "<link>" -Target "<source>"
Create symbolic link for directory
cmd
mklink /d <link> <source>
PowerShell
New-Item -ItemType SymbolicLink -Path "<link>" -Target "<source>"
Create hard link
cmd
mklink /h <link> <source>
PowerShell
New-Item -ItemType HardLink -Path "<link>" -Target "<source>"
Create directory junction
Hard link for directory
PowerShell
New-Item -ItemType Junction -Path "<link>" -Target "<source>"
cmd
mklink /j <link> <source>